﻿//Ana Isabel Ibáñez García
//version 1: create the window with the controls
//version 7: both constructors,buttonCancel_Click,buttonAccept_Click

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UMLDesigner
{
    public partial class ParametersWindow : Form
    {
        bool modifyMode = false;
        public ParametersWindow()
        {
            InitializeComponent();
            listBoxType.DataSource = DataType.GetTypes();
        }

        public ParametersWindow(ParameterData p) : this()
        {
            modifyMode = true;
            textBoxName.Text = p.GetName();
            listBoxType.Text = p.GetParamType();
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void buttonAccept_Click(object sender, EventArgs e)
        {
            if (!modifyMode)
            {
                MethodsWindow v = (MethodsWindow)Owner;
                v.AddParameter(textBoxName.Text, listBoxType.Text);
            }
            else
            {
                MethodsWindow v = (MethodsWindow)Owner;
                v.ModifyParameter(textBoxName.Text, listBoxType.Text);
            }
            this.Close();
        }
    }
}
